﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Effect3 : ParticleEffectBase
{

    public List<ParticleSystem> _partycleSystems = new List<ParticleSystem>();
    List<ParticleSystem.ShapeModule> shapeModules;

    protected override void Init()
    {
        base.Init();
        shapeModules = new List<ParticleSystem.ShapeModule>();
        for (int i = 0; i < _partycleSystems.Count; i++)
        {
            shapeModules.Add(_partycleSystems[i].shape);
        }
    }

    // Update is called once per frame
    protected override void Update()
    {
        base.Update();

        if (!_isUseAmpM) return;

        float ampMultiplier = MainController.Instance._musicCore.ampMultiplier;

        if (_isUseOffset)
        {
            Vector2 ran_dirction = Random.insideUnitCircle;
            Vector3 Dir = new Vector3(ran_dirction.x, 3, ran_dirction.y);
            transform.position = _startPostion + Dir * ampMultiplier * _settingData._effect_pathOffsetRadio;
        }

        for (int i = 0; i < shapeModules.Count; i++)
        {
            ParticleSystem.MainModule main = _partycleSystems[i].main;
            main.gravityModifierMultiplier = _gravityRadio * ampMultiplier * _gravityMultper;
            main.startColor = _particleGraientColor.Evaluate(ampMultiplier / 1.2f);
        }

        transform.localScale = _startEffectScale * (1 + ampMultiplier * _scaleRadio * _settingData._effect_Strengh);
    }
}
